Skip to content

chore(miner): migrate batch 4.4 foundational lib modules to TypeScript - #7383

Merged
JSONbored merged 2 commits into
JSONbored:mainfrom
tryeverything24:migrate-miner-lib-batch-4-4-typescript
Jul 20, 2026
Merged

chore(miner): migrate batch 4.4 foundational lib modules to TypeScript#7383
JSONbored merged 2 commits into
JSONbored:mainfrom
tryeverything24:migrate-miner-lib-batch-4-4-typescript

Conversation

@tryeverything24

Copy link
Copy Markdown
Contributor

Closes #7312

Summary

Part of the phased packages/loopover-miner/lib/** TypeScript migration (parent #7290, Phase 1 #7299 merged). This is batch 4.4 of 8 (Phase 4): converts these 8 files from hand-maintained .js/.d.ts pairs to real, compiler-verified .ts source, compiled in place via the package's existing tsc build pipeline (same in-place-emit pattern Phase 1 wired up):

  • lib/ams-policy.js
  • lib/rejection-templates.js
  • lib/calibration-types.js
  • lib/opportunity-fanout.js
  • lib/discovery-index-client.js
  • lib/contribution-profile-cache.js
  • lib/plan-store.js
  • lib/attempt-runner.js

No tsconfig.json changes needed (the existing bin/**/*.ts, lib/**/*.ts include glob picks up the newly-converted files automatically). No behavior change — existing tests continue to pass unmodified; a small number of test-only additions extend coverage of pre-existing defensive branches that the migration's stricter compiled type-checking newly surfaced as reachable-but-untested.

Scope checklist

  • All 8 files in this batch converted from .js to .ts
  • Each file's hand-maintained .d.ts sibling removed (tsc regenerates it, committed alongside the .ts source)
  • Compiled .js/.d.ts build output regenerated and committed
  • Zero behavior change; existing tests pass unmodified
  • Every changed file driven to 100% statement/branch/function/line coverage

Test plan

  • npm run typecheck (root) — clean
  • npm run build --workspace @loopover/engine && npm run build --workspace @loopover/miner — clean, node --check passes for all 121 files
  • Targeted suite for all 8 converted modules (15 test files, 205 tests) — all pass, 100% coverage on every converted file (verified via coverage-summary.json, not just the terminal table)
  • npm run actionlint, db:schema-drift:check, selfhost:env-reference:check, miner:env-reference:check, docs:drift-check, branding-drift:check, manifest:drift-check, engine-parity:drift-check, release-manifest:sync:check, command-reference:check — all clean
  • npm run test:mcp-pack, npm run test:miner-pack, npm run test:miner-deployment-docs-audit — all clean, converted files' .js/.d.ts present in the packed file list
  • npx vitest run --config vitest.workers.config.ts — clean
  • npm run ui:openapi:check, npm run ui:typecheck, npm run ui:lint — clean (one cross-package type error caught by ui:typecheck's stricter exactOptionalPropertyTypes config, not caught by the root typecheck, was fixed)
  • npm audit — 2 pre-existing high-severity advisories in github-actionlint's adm-zip dependency (no fix available), unrelated to this diff
  • Rebased onto current upstream/main immediately before pushing

Converts ams-policy, rejection-templates, calibration-types, opportunity-fanout,
discovery-index-client, contribution-profile-cache, plan-store, and attempt-runner
from hand-maintained .js/.d.ts pairs to real .ts source, compiled in place via the
package's existing tsc build pipeline. Extends targeted unit tests to drive every
converted file to 100% statement/branch/function/line coverage.
@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@loopover-orb loopover-orb Bot added the gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. label Jul 19, 2026
…ed opportunity-fanout.js

tsc's printer left a trailing space at the end of the fetchWithRetry(...) call's first
line when an inline comment sat between two of its arguments in the .ts source -- caught
by CI's git diff --check gate. Hoists the comment above the call and extracts the options
object into a named retryOptions variable instead; no behavior change.
@loopover-orb

loopover-orb Bot commented Jul 19, 2026

Copy link
Copy Markdown
Contributor

Warning

⏸️ LoopOver review result - manual review recommended

Review updated: 2026-07-19 23:54:50 UTC

31 files · 1 AI reviewer · no blockers · CI green · unstable

⏸️ Suggested Action - Manual Review

Review summary
This is a mechanical TS migration (batch 4.4 of 8) of 8 foundational miner lib modules: each `.js`/`.d.ts` pair is replaced by a compiler-verified `.ts` source with a regenerated compiled `.js`/`.d.ts` output committed alongside it. Comparing the visible `.ts` sources against the pre-existing `.js`/`.d.ts` content (e.g. `ams-policy.ts` vs `ams-policy.js`/`.d.ts`, `attempt-runner.ts` vs its compiled output, `plan-store.ts`'s validation/migration logic) shows the runtime logic, error handling, and exported surface are preserved byte-for-byte in behavior — only types and comments were added. The PR closes #7312 as required, and the compiled `.js` diffs are pure formatting/whitespace churn from tsc re-emission rather than logic changes.

Nits — 5 non-blocking
  • `discovery-index-client.ts:50`'s 'Master opt-in' comment reads fine in context (describing the top-level env-var toggle), but consider 'Primary opt-in' for consistency with the flagged terminology guidance.
  • `opportunity-fanout.ts` is a 795-line single file (up from an already-large predecessor) — this migration batch would be a good opportunity to note it as a future split candidate even though splitting it now is out of scope for a behavior-preserving conversion.
  • Several new numeric literals (304, 404, 60_000, plan-store's 300/60/50/2000 bound constants) surfaced by the stricter TS pass are inherited as-is from the original `.js`/`.d.ts` pair rather than newly introduced — no action needed, but worth confirming none of these silently drifted from the hand-maintained `.d.ts` values during the port.
  • The `return null` catch-and-swallow patterns in `ams-policy.ts`, `contribution-profile-cache.ts`, and `opportunity-fanout.ts` are all pre-existing, intentional fail-open behavior (each has an explanatory comment) carried over unchanged from the `.js` originals, not new defensive gaps introduced by this PR.
  • If not already covered elsewhere in the batch series, add a short note in the parent tracking issue (chore(miner): migrate packages/loopover-miner from plain .js + hand-maintained .d.ts to real TypeScript #7290) confirming byte-for-byte behavioral parity was spot-checked for this batch, the same way Build a real production runSlopAssessment implementation #5133's slop-assessment port was byte-parity-verified — useful precedent for reviewers who can't diff every compiled `.js` line by eye.

Decision drivers

  • ✅ Code review — No blockers (1 reviewer)
  • ✅ Gate result — Passing (No configured blocker found.)
Context & advisory signals — never blocks the verdict
Signal Result Evidence
Linked issue ✅ Linked #7312
Related work ⚠️ 3 scoped overlaps Top overlaps are listed below; lower-confidence bulk is hidden.
Change scope ❌ 8/20 High review scope from cached public metadata (1 linked issue).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 49 registered-repo PR(s), 18 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor tryeverything24; Gittensor profile; 49 PR(s), 0 issue(s).
Improvement ✅ Minor risk: clean · value: minor · LLM: moderate
Review context
  • Author: tryeverything24
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, TypeScript, Python, HTML, C++, Java, PHP, C#
  • Official Gittensor activity: 49 PR(s), 0 issue(s).
  • Related work: Titles/paths share 9 meaningful terms. (issue #7300)
  • Related work: Titles/paths share 11 meaningful terms. (issue #7329, issue #7328)
  • Related work: Titles/paths share 10 meaningful terms. (issue #7329, issue #7330)
  • Additional title-only matches omitted; title-only overlap does not block.
Contributor next steps
  • Start here: Review top overlaps.
  • Then work through the remaining 2 steps in the Signals table above.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.
🧪 Chat with LoopOver

Ask LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.

  • @loopover ask <question> answers contribution-quality Q&A with source citations and freshness.
  • @loopover chat <question> answers in natural prose from cached decision-pack facts via local inference (maintainer/collaborator; read-only).
  • A plain-language @loopover mention with a real question is routed to the closest matching read-only command automatically — no exact syntax required.

Full command reference: https://loopover.ai/docs/loopover-commands

🧪 Experimental — new and may change.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by LoopOver, a quiet PR intelligence layer for OSS maintainers.

  • Re-run LoopOver review

@loopover-orb loopover-orb Bot added the manual-review Gittensor contributor context label Jul 19, 2026
@codecov

codecov Bot commented Jul 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.15%. Comparing base (6c834ab) to head (de94afb).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7383      +/-   ##
==========================================
+ Coverage   91.13%   91.15%   +0.02%     
==========================================
  Files         715      715              
  Lines       72579    72648      +69     
  Branches    20166    20360     +194     
==========================================
+ Hits        66143    66225      +82     
+ Misses       5394     5381      -13     
  Partials     1042     1042              
Flag Coverage Δ
shard-1 41.53% <45.13%> (-0.07%) ⬇️
shard-2 35.33% <41.14%> (-0.13%) ⬇️
shard-3 31.45% <15.45%> (-0.18%) ⬇️
shard-4 30.59% <38.19%> (-1.13%) ⬇️
shard-5 30.93% <59.54%> (+0.56%) ⬆️
shard-6 43.59% <35.59%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
packages/loopover-miner/lib/ams-policy.ts 100.00% <100.00%> (ø)
packages/loopover-miner/lib/attempt-runner.ts 100.00% <100.00%> (ø)
packages/loopover-miner/lib/calibration-types.ts 100.00% <100.00%> (ø)
...s/loopover-miner/lib/contribution-profile-cache.ts 100.00% <100.00%> (ø)
...kages/loopover-miner/lib/discovery-index-client.ts 100.00% <100.00%> (ø)
packages/loopover-miner/lib/opportunity-fanout.ts 100.00% <100.00%> (ø)
packages/loopover-miner/lib/plan-store.ts 100.00% <100.00%> (ø)
packages/loopover-miner/lib/rejection-templates.ts 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

@JSONbored
JSONbored merged commit efe451e into JSONbored:main Jul 20, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:feature Gittensor-scored feature linked to a feature issue — scores a 0.25x multiplier. manual-review Gittensor contributor context

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(miner): migrate foundational, most-depended-on packages/loopover-miner/lib modules to TypeScript (batch 4.4 of 8 (Phase 4))

2 participants